﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace EasyBuildingCMS.BuildingBlocks
{
    public abstract class BaseBuildingBlock : System.Web.UI.UserControl
    {
        private BuildingBlockWrapper innerBuildingBlockWrapper;
        protected BuildingBlockWrapper InnerBuildingBlockWrapper
        {
            get 
            {   
                return innerBuildingBlockWrapper;           
            }

            set 
            {
                innerBuildingBlockWrapper = value;
            }

        }

        public int BuildingBlockInstanceID
        {
            get { return this.InnerBuildingBlockWrapper.BuildingBlockInstanceID; }
            set { this.InnerBuildingBlockWrapper.BuildingBlockInstanceID = value; }
        }

        public string BuildingBlockInstanceTitle
        {
            get { return this.InnerBuildingBlockWrapper.BuildingBlockInstanceTitle; }
            set { this.InnerBuildingBlockWrapper.BuildingBlockInstanceTitle = value; }
        }

        public BaseBuildingBlock()
        {
            if (InnerBuildingBlockWrapper != null) return;
            this.InnerBuildingBlockWrapper = (BuildingBlockWrapper)this.LoadControl("~/BuildingBlocks/BuildingBlockWrapper.ascx");
            this.Controls.Add(InnerBuildingBlockWrapper);
                    
            Init();
          
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void BindFrontEndControl(Control control)
        {
            this.InnerBuildingBlockWrapper.BindBuildingBlockControl(control);
        }

        protected abstract void Init();
           

    }
}